<template>
  <div>
    <a-select v-model="option" style="width: 50px">
      <a-select-option value="date">
        天
      </a-select-option>
      <a-select-option value="mounth">
        月
      </a-select-option>
    </a-select>
    <a-date-picker v-if="option === 'date'" v-model="date" style="width: 140px" placeholder="请选择日期"/>
    <a-month-picker v-else v-model="date" style="width: 140px" placeholder="请选择月份"/>
    <a-button type="primary" @click="searchBtnClick">
      收索
    </a-button>
  </div>
</template>

<script lang="ts">
import timestamp from 'time-stamp'
import { Vue, Component } from 'vue-property-decorator'

@Component({
  name: 'ComSearchBarDayMonth'
})
export default class ComSearchBarDayMonth extends Vue {
  option = 'date'
  date:any = null

  searchBtnClick () {
    this.$emit('searchClick', {
      option: this.option,
      date: this.date,
      dateStr: this.date
        ? this.date.format(
          `YYYY-MM${this.option === 'date' ? '-DD' : ''}`,
          this.date
        )
        : null
    })
  }
}
</script>

<style scoped></style>
